<template>
	<div class="jumbotron">
		<h1>{{hintText}}</h1>
		<br/>
		<p>欢迎您，{{sysUser.username}}</p>
		<br/>
		<p>{{JSON.stringify(sysUser)}}</p>
		<div v-if="sysUser.permission===1">
			<p>企业名称：{{enterpriseInfo.entName?enterpriseInfo.entName:"未完善"}}</p>
			<p>企业所在地点：{{enterpriseInfo.region?enterpriseInfo.region:"未完善"}}</p>
			<p>企业描述：{{enterpriseInfo.information?enterpriseInfo.information:"未完善"}}</p>
			<p>认证状态：{{enterpriseInfo.verified===0?"未认证":"已认证"}}</p>
		</div>
	</div>
</template>

<script>
	module.exports = {
		data: function() {
			return {
				hintText: '欢迎登陆仁爱招聘网！',
				sysUser: {
					permission: 2
				},
				enterpriseInfo: {

				},
			}
		},
		watch: {
			sysUser: function(val) {
				if (val.permission === 1) {
					$.ajax({
						url: conf.ur + "/api/enterprise/getEnterpriseInfo?userId=" + this.sysUser.id,
						type: 'get',
						headers: {
							"Content-Type": "application/json",
							"x-auth-token": window.localStorage.getItem('x-auth-token')
						},
						success: (data) => {
							if (data.code === 0) {
								this.enterpriseInfo = data.data;
							}
						},
						error: (err) => {
							console.log("网络异常！")
						}
					});
				}
			},
		},
		mounted() {
			this.sysUser = JSON.parse(localStorage.getItem('sysUser'));
		},
	}
</script>
